#ifndef float4_impl_h__
#define float4_impl_h__

#include <memory.h>

inline float4::float4(float* d) {
  memcpy((float*)data.a, d, sizeof(data.a));
}

inline float4::float4(const float4& other) {
  memcpy((float*)data.a, (float*)other.data.a, sizeof(data.a));
}

inline float4::float4(float x, float y, float z, float w) {
  data.a[0] = x;
  data.a[1] = y;
  data.a[2] = z;
  data.a[3] = w;
}

inline float4& float4::operator=(const float4& other) {
  memcpy((float*)data.a, (float*)other.data.a, sizeof(data.a));
}

inline bool float4::operator==(const float4& other) {
  return !memcmp(data.a, other.data.a, sizeof(data.a));
}

inline float4 float4::add(const float4& add) const {
  return float4(data.a[0] + add.data.a[0],
                data.a[1] + add.data.a[1],
                data.a[2] + add.data.a[2],
                data.a[3] + add.data.a[3]);
}

inline float4 float4::sub(const float4& subtract) const {
  return float4(data.a[0] - subtract.data.a[0],
                data.a[1] - subtract.data.a[1],
                data.a[2] - subtract.data.a[2],
                data.a[3] - subtract.data.a[3]);
}

inline float4 float4::mul(const float4& multiply) const {
  return float4(data.a[0] * multiply.data.a[0],
                data.a[1] * multiply.data.a[1],
                data.a[2] * multiply.data.a[2],
                data.a[3] * multiply.data.a[3]);
}

inline float4 float4::madd(const float4& multiply, const float4& add) const {
  return float4(data.a[0] * multiply.data.a[0] + add.data.a[0],
                data.a[1] * multiply.data.a[1] + add.data.a[1],
                data.a[2] * multiply.data.a[2] + add.data.a[2],
                data.a[3] * multiply.data.a[3] + add.data.a[3]);
}

inline float4 float4::msub(const float4& multiply, const float4& subtract) const {
  return float4(data.a[0] * multiply.data.a[0] - subtract.data.a[0],
                data.a[1] * multiply.data.a[1] - subtract.data.a[1],
                data.a[2] * multiply.data.a[2] - subtract.data.a[2],
                data.a[3] * multiply.data.a[3] - subtract.data.a[3]);
}


inline float4 float4::recip() const {
  return float4(1.0f / data.a[0],
                1.0f / data.a[1],
                1.0f / data.a[2],
                1.0f / data.a[3]);
}




#endif // float4_impl_h__